﻿<%@ Page Title="" Language="VB" MasterPageFile="~/Master/Site_InnerWeb.master" ValidateRequest="false"
    AutoEventWireup="false" CodeFile="MyCredit.aspx.vb" Inherits="private_secure_members_manage_MyCredit" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 91px;
        }
        .auto-style1 {
            height: 43px;
        }
        .auto-style2
        {
            width: 468px;
        }
        .auto-style3
        {
            height: 43px;
            width: 468px;
        }
        .auto-style4 {
            width: 468px;
            height: 25px;
        }
        .auto-style5 {
            height: 25px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <h2>Manage Credits</h2>
    <h3>Buy Your Credit Ready To Contact Your Customers</h3>
    <hr />
    <br />
    <table id="table1" class="style1">
        <tr>
            <td class="auto-style2">
                <strong>Choose your Organisation/Business:</strong>
                <br />
                <asp:DropDownList ID="ddlEntity" runat="server" DataSourceID="SqlEntity_ds" DataTextField="Name"
                    DataValueField="ID" Width="250px" AutoPostBack="True" 
                    AppendDataBoundItems="True">
                    <asp:ListItem Value="0">Select Item from List</asp:ListItem>
                </asp:DropDownList>
                &nbsp;
                <br />
                <asp:Button ID="btnBuyCredit" runat="server" Text="Buy Credits" />
                <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
                <br />
                <asp:SqlDataSource ID="SqlEntity_ds" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                    SelectCommand="usp_GetEntityList_ByPersonId" 
                    SelectCommandType="StoredProcedure">
                    <SelectParameters>
                        <asp:Parameter Name="PersonId" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="auto-style3">
                </td>
            <td class="auto-style1">
                </td>
            <td class="auto-style1">
                </td>
        </tr>
         <tr>
            <td valign="top" class="auto-style2">
                <strong>Credits - Totals</strong>
                <asp:GridView ID="GridView1" runat="server" CellPadding="4" 
                    DataSourceID="EntityCredit_ds" ForeColor="#333333" 
                    AutoGenerateColumns="False" DataKeyNames="Id" AllowPaging="True" AllowSorting="True" EmptyDataText="Please Choose an Organisation ">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" 
                            SortExpression="Id" Visible="False" />
                        <asp:BoundField DataField="EntityId" HeaderText="EntityId" 
                            SortExpression="EntityId" Visible="False" />
                        <asp:BoundField DataField="Purchased" HeaderText="Purchased" ReadOnly="True" 
                            SortExpression="Purchased" />
                        <asp:BoundField DataField="Used" HeaderText="Used" ReadOnly="True" 
                            SortExpression="Used" />
                        <asp:BoundField DataField="Refunded" HeaderText="Refunded" ReadOnly="True" 
                            SortExpression="Refunded" />
                        <asp:BoundField DataField="Balance" HeaderText="Balance" ReadOnly="True" 
                            SortExpression="Balance" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
                <asp:SqlDataSource ID="EntityCredit_ds" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                    DeleteCommand="pay.usp_EntityCreditDelete" DeleteCommandType="StoredProcedure" 
                    InsertCommand="pay.usp_EntityCreditInsert" InsertCommandType="StoredProcedure" 
                    SelectCommand="pay.usp_EntityCreditSelectByEntityId" 
                    SelectCommandType="StoredProcedure" UpdateCommand="pay.usp_EntityCreditUpdate" 
                    UpdateCommandType="StoredProcedure">
                    <DeleteParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="EntityId" Type="Int32" />
                        <asp:Parameter Name="Purchased" Type="Int32" />
                        <asp:Parameter Name="Used" Type="Int32" />
                        <asp:Parameter Name="Refunded" Type="Int32" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="ddlEntity" Name="EntityId" 
                            PropertyName="SelectedValue" Type="Int32" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                        <asp:Parameter Name="EntityId" Type="Int32" />
                        <asp:Parameter Name="Purchased" Type="Int32" />
                        <asp:Parameter Name="Used" Type="Int32" />
                        <asp:Parameter Name="Refunded" Type="Int32" />
                        <asp:Parameter Name="Balance" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <br />
                <strong>Credits - Usage History</strong><asp:GridView ID="GridView3" runat="server" CellPadding="4" ForeColor="#333333" 
                    AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
                    DataKeyNames="Id" DataSourceID="EntityCreditUsage_ds" EmptyDataText="No Credits Usage History data available yet">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" 
                            SortExpression="Id" Visible="False" />
                        <asp:BoundField DataField="EntityId" HeaderText="EntityId" 
                            SortExpression="EntityId" Visible="False" />
                        <asp:BoundField DataField="PersonId" HeaderText="PersonId" 
                            SortExpression="PersonId" Visible="False" />
                        <asp:BoundField DataField="RecipientsCount" HeaderText="Recipients Count" 
                            SortExpression="RecipientsCount" />
                        <asp:BoundField DataField="MessagesCount" HeaderText="Messages Count" 
                            SortExpression="MessagesCount" />
                        <asp:BoundField DataField="DisplayName" HeaderText="Display Name" 
                            SortExpression="DisplayName" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
                <asp:SqlDataSource ID="EntityCreditUsage_ds" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                    DeleteCommand="pay.usp_EntityCreditUsageDelete" DeleteCommandType="StoredProcedure" 
                    InsertCommand="pay.usp_EntityCreditUsageInsert" InsertCommandType="StoredProcedure" 
                    SelectCommand="pay.usp_EntityCreditUsageSelectByEntityId" 
                    SelectCommandType="StoredProcedure" UpdateCommand="pay.usp_EntityCreditUsageUpdate" 
                    UpdateCommandType="StoredProcedure">
                    <DeleteParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                        <asp:Parameter Name="EntityId" Type="Int32" />
                        <asp:Parameter Name="PersonId" Type="Int32" />
                        <asp:Parameter Name="RecipientsCount" Type="Int32" />
                        <asp:Parameter Name="MessagesCount" Type="Int32" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="ddlEntity" Name="EntityId" 
                            PropertyName="SelectedValue" Type="Int32" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                        <asp:Parameter Name="EntityId" Type="Int32" />
                        <asp:Parameter Name="PersonId" Type="Int32" />
                        <asp:Parameter Name="RecipientsCount" Type="Int32" />
                        <asp:Parameter Name="MessagesCount" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <br />
             </td>
            <td>&nbsp;</td>
            <td valign="top">
                <strong>Credits - Purchases History</strong><asp:GridView
                    ID="GridView2" runat="server"
                    CellPadding="4" ForeColor="#333333" AllowPaging="True" AllowSorting="True"
                    DataSourceID="EntityCreditPurchase_ds" AutoGenerateColumns="False"
                    DataKeyNames="Id" EmptyDataText="No Credits Purchase History Information yet">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True" SortExpression="Id" Visible="False" />
                        <asp:BoundField DataField="EntityId" HeaderText="EntityId" SortExpression="EntityId" Visible="False" />
                        <asp:BoundField DataField="PersonId" HeaderText="PersonId" SortExpression="PersonId" Visible="False" />
                        <asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" SortExpression="Name" />
                        <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                        <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
                        <asp:BoundField DataField="Unit Price" HeaderText="Unit Price" SortExpression="Unit Price" />
                        <asp:BoundField DataField="Units" HeaderText="Units" SortExpression="Units" />
                        <asp:BoundField DataField="VAT Amount" HeaderText="VAT Amount" SortExpression="VAT Amount" />
                        <asp:BoundField DataField="Total" HeaderText="Total" SortExpression="Total" />
                        <asp:BoundField DataField="ActionDate" HeaderText="ActionDate" SortExpression="ActionDate" />
                        <asp:BoundField DataField="ItemId" HeaderText="ItemId" SortExpression="ItemId" Visible="False" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
                <asp:SqlDataSource ID="EntityCreditPurchase_ds" runat="server"
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                    DeleteCommand="pay.usp_PayRequestDelete" DeleteCommandType="StoredProcedure"
                    InsertCommand="pay.usp_PayRequestInsert" InsertCommandType="StoredProcedure"
                    SelectCommand="pay.usp_PayRequestsByEntityId"
                    SelectCommandType="StoredProcedure" UpdateCommand="pay.usp_PayRequestUpdate"
                    UpdateCommandType="StoredProcedure">
                    <DeleteParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="EntityId" Type="Int32" />
                        <asp:Parameter Name="PersonId" Type="Int32" />
                        <asp:Parameter Name="PayMethodId" Type="Int32" />
                        <asp:Parameter Name="CurrencyId" Type="Int32" />
                        <asp:Parameter Name="Quantity" Type="Int32" />
                        <asp:Parameter Name="UnitPrice" Type="Decimal" />
                        <asp:Parameter Name="ProductId" Type="String" />
                        <asp:Parameter Name="ItemId" Type="Int32" />
                        <asp:Parameter Name="Shipping" Type="Decimal" />
                        <asp:Parameter Name="SubTotal" Type="Decimal" />
                        <asp:Parameter Name="VatRateId" Type="Int32" />
                        <asp:Parameter Name="VatAmount" Type="Decimal" />
                        <asp:Parameter Name="Total" Type="Decimal" />
                        <asp:Parameter Name="Status" Type="String" />
                        <asp:Parameter Name="CardDetailsId" Type="Int32" />
                        <asp:Parameter Name="ActionDate" Type="DateTime" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="ddlEntity" Name="EntityId"
                            PropertyName="SelectedValue" Type="Int32" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                        <asp:Parameter Name="EntityId" Type="Int32" />
                        <asp:Parameter Name="PersonId" Type="Int32" />
                        <asp:Parameter Name="PayMethodId" Type="Int32" />
                        <asp:Parameter Name="CurrencyId" Type="Int32" />
                        <asp:Parameter Name="Quantity" Type="Int32" />
                        <asp:Parameter Name="UnitPrice" Type="Decimal" />
                        <asp:Parameter Name="ProductId" Type="String" />
                        <asp:Parameter Name="ItemId" Type="Int32" />
                        <asp:Parameter Name="Shipping" Type="Decimal" />
                        <asp:Parameter Name="SubTotal" Type="Decimal" />
                        <asp:Parameter Name="VatRateId" Type="Int32" />
                        <asp:Parameter Name="VatAmount" Type="Decimal" />
                        <asp:Parameter Name="Total" Type="Decimal" />
                        <asp:Parameter Name="Status" Type="String" />
                        <asp:Parameter Name="CardDetailsId" Type="Int32" />
                        <asp:Parameter Name="ActionDate" Type="DateTime" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <br />
                Credits - Invoices<br />
                <asp:GridView ID="GridView4" runat="server" DataSourceID="EntityInvoice_ds" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="Id" ForeColor="#333333" GridLines="None">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True" SortExpression="Id" Visible="False" />
                        <asp:BoundField DataField="EntityId" HeaderText="EntityId" SortExpression="EntityId" Visible="False" />
                        <asp:BoundField DataField="PayRequestId" HeaderText="PayRequestId" SortExpression="PayRequestId" Visible="False" />
                        <asp:BoundField DataField="InvoiceNo" HeaderText="InvoiceNo" SortExpression="InvoiceNo" />
                        <asp:BoundField DataField="Invoice Date" HeaderText="Invoice Date" SortExpression="Invoice Date" />
                        <asp:BoundField DataField="AddressId" HeaderText="AddressId" SortExpression="AddressId" Visible="False" />
                        <asp:BoundField DataField="Order Number" HeaderText="Order Number" SortExpression="Order Number" />
                        <asp:BoundField DataField="Account No" HeaderText="Account No" SortExpression="Account No" />
                        <asp:BoundField DataField="ProductId" HeaderText="ProductId" SortExpression="ProductId" Visible="False" />
                        <asp:BoundField DataField="ItemId" HeaderText="ItemId" SortExpression="ItemId" Visible="False" />
                        <asp:BoundField DataField="Unit Price" HeaderText="Unit Price" SortExpression="Unit Price" />
                        <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
                        <asp:BoundField DataField="VATRateId" HeaderText="VATRateId" SortExpression="VATRateId" Visible="False" />
                        <asp:BoundField DataField="VAT Rate" HeaderText="VAT Rate" SortExpression="VAT Rate" />
                        <asp:BoundField DataField="VAT Amount" HeaderText="VAT Amount" SortExpression="VAT Amount" />
                        <asp:BoundField DataField="Total" HeaderText="Total" SortExpression="Total" />
                        <asp:BoundField DataField="CurrencyId" HeaderText="CurrencyId" SortExpression="CurrencyId" Visible="False" />
                        <asp:BoundField DataField="Currency" HeaderText="Currency" SortExpression="Currency" />
                        <asp:BoundField DataField="PaymentMethodId" HeaderText="PaymentMethodId" SortExpression="PaymentMethodId" Visible="False" />
                        <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
                <asp:SqlDataSource ID="EntityInvoice_ds" runat="server" 
                 ConnectionString ="<%$ ConnectionStrings:ApplicationServices %>" SelectCommand="pay.usp_EntityInvoiceSelectByEntityPayRequestId" SelectCommandType="StoredProcedure">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="ddlEntity" Name="EntityId" PropertyName="SelectedValue" Type="Int32" />
                        <asp:ControlParameter ControlID="GridView2" Name="PayRequestId" PropertyName="SelectedValue" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
         <tr>
            <td class="auto-style2">
                &nbsp;</td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
         <tr>
            <td class="auto-style2">
                &nbsp;</td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
         <tr>
            <td valign="top" class="auto-style4">
             </td>
            <td class="auto-style5">
                </td>
            <td class="auto-style5">
                </td>
        </tr>
         <tr>
            <td class="auto-style2">
                &nbsp;</td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>

</asp:Content>
